Repository navigation
feat(auth): add OpenID Connect sign-in - #9
Open
ParadoxPixel wants to merge 3 commits into
Open
ParadoxPixel wants to merge 3 commits into
ParadoxPixel wants to merge 3 commits into
Conversation
Lets Arca run behind an identity provider without separate password accounts. Off unless OIDC_ISSUER is set. - code flow with PKCE, state and nonce, ending in the normal session - accounts linked by issuer and subject, never by email alone - OIDC_ADMIN_GROUPS syncs the role each sign-in; last admin kept - OIDC_ALLOWED_GROUPS gates sign-in; OIDC_LINK_EXISTING opts in to linking an existing account by email - passwordless accounts get the decoy hash at password login so timing does not reveal them
An instance behind a provider should need no password account at all. Before setup a provider sign-in creates nothing: verified claims wait in memory under a cookie until the wizard makes them the admin, with the setup token still required and the shown email echoed back so a second tab cannot swap the identity. With admin groups set only a member may do this, so later role sync never demotes the setup admin.
With admin groups set, a role edited in Arca was silently undone at the user's next sign-in. Linked accounts now refuse role edits, and the users table marks SSO accounts with a key badge and explains the locked role in a tooltip. Also widens the role select, which cut off "Administrator".
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds single sign-on through any OpenID Connect provider. I wanted to run Arca behind my own
identity provider without keeping a separate password account around, so the setup wizard can
take its administrator from the provider too.
It is off by default. An instance that does not set
OIDC_ISSUERbehaves exactly as before.Sign-in is the authorization code flow with PKCE, state and nonce, and it ends in the same session
cookie as a password login, so nothing behind the login changes. Accounts are matched on the
provider's issuer and subject, kept in a new
user_identitiestable. Arca never matches on emailalone, because that would let anyone who can set an email at the provider into the matching
account. A user whose email changes at the provider keeps their account. Accounts created this way
have no password, and password login refuses them.
With
OIDC_ADMIN_GROUPSset, the role of a linked account follows group membership on everysign-in, and the last enabled administrator is never demoted. The user list then locks the role of
those accounts, since a change made in Arca would be undone at the next sign-in. Without admin
groups Arca leaves roles alone. The display name comes from the provider only when the account is
created, so a name edited in Arca stays.
OIDC_ALLOWED_GROUPSturns away anyone outside thosegroups, and a sign-in whose email already belongs to an account is refused unless
OIDC_LINK_EXISTINGis on.Before setup, a provider sign-in creates nothing. It only fills in the wizard's administrator step,
and the setup token is still required. With admin groups set, only a member of one can do this,
since the role sync would otherwise demote the setup administrator at their next sign-in.
Maven, npm and Docker clients keep using API tokens. Configuration is env vars and flags, and
docs/oidc.mdhas the table and an Authentik example.I left a few things out on purpose. Mapping groups to per-repository grants needs a schema change
and did not belong in a first version. OIDC is not configurable from the admin UI, and GitHub login
without an OIDC provider in between is not supported. Removing someone at the provider takes effect
at their next sign-in only, while their sessions and API tokens outlive it.
docs/oidc.mdsays so.Two new dependencies come in,
coreos/go-oidc/v3andgolang.org/x/oauth2. The second requiresgo 1.26.0ingo.mod.go mod tidyalso moved the existing direct dependencies out of the// indirectblock, which is why that diff looks bigger than it is. I exportedauth.isSecuresothe OIDC cookies follow the same Secure rule as the session cookie. Identities waiting for setup
live in server memory, so nothing reaches the database before the setup transaction and a restart
only means signing in again. While the browser is away at the provider, the wizard keeps its fields,
setup token included, in sessionStorage. I accepted that over moving the button to the first step,
because the token is useless once setup completes and the wizard's flow stays as it was.
Password login now runs the decoy hash for accounts without a password too, so the response time
does not tell an SSO account apart from an unknown email.
go vet,go test ./...andpnpm typecheckpass. The OIDC tests run against a fake provider thatsigns real ID tokens. On the final commit I ran a scripted browser pass against Keycloak 26 with the
image built from the Dockerfile. It covered the refusal of a non-admin at setup, setup through the
provider as an admin, sign-in after setup with roles from groups, the locked role in the user list,
and refusal outside the allowed groups. The build has also been running in my own production
instance against Authentik. I have not tried a provider that leaves the groups claim out of the ID
token.
To implement this feature I made use of Claude Fable 5.2.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.